<%@page import="java.util.List"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html>
<%@ include file="/WEB-INF/view-system/include/contentTaglib.jsp"%>
<%@ include file="/WEB-INF/view-system/include/myTaglib.jsp"%>

<html>
<head>
	<title>员工信息页面</title>
	<script src="${ctxStaticSystem }/js/staff/staff.js" type="text/javascript" ></script>
	<link href="${ctx}/static-system/css/staff/staff.css" rel="stylesheet" type="text/css"/>
</head> 
<body>
<tags:dataSet id="staffInfo">
	<tags:dataField name="staffName" display="用户名称" sort="false"  cssClass="table-header-center"/>
	<tags:dataField name="staffOrgName" display="所属部门" sort="false" cssClass="table-header-center"/>
	<tags:dataField name="staffId" display="用户编号" sort="false" cssClass="table-header-center"/>
	<tags:dataField name="staffCreateTime" display="创建日期" sort="false" cssClass="table-header-center"/>
	<tags:dataField name="staffLastLogin" display="最后登录日期" sort="false" cssClass="table-header-center"/>
	<tags:dataField name="state" display="状态" sort="false" cssClass="table-header-center"/>
	<tags:dataField name="staffType" display="操作" sort="false" width="5%" cssClass="table-header-center"/>
</tags:dataSet>

<tags:ajax id="queryOrgsAjax" url="${ctx}/sys/orgMgr/queryAllOrg" type="post"
	onBeforeSend="showTr.showloading" onComplete="showTr.closeloading"/>


<tags:ajax id="queryStaffListAjax" url="${ctx}/sys/staffMgr/queryLst" type="post"
	contentType="application/x-www-form-urlencoded"
	autoSend="false" formQuery="#staffQueryFrm" formSubmit="true" />
<!-- 新增员工 -->
<tags:ajax id="addStaffAjax" url="${ctx }/sys/staffMgr/addStaff" autoSend='false' type='post' formQuery="#createStaffFrm"
		   formSubmit="true" contentType="application/x-www-form-urlencoded" onSuccess="onSaveStaffSucc" />
<!-- 删除员工 -->
<tags:ajax id="delStaffAjax" url="${ctx }/sys/staffMgr/delStaff" autoSend="false" contentType="application/x-www-form-urlencoded"
		   type="post" onSuccess="onDeleSucc"/>
<!-- 修改员工 -->
<tags:ajax id="updateStaffAjax" url="${ctx }/sys/staffMgr/updateStaff" autoSend="false" contentType="application/x-www-form-urlencoded"
		   formQuery="#updateStaffFrm"
		   formSubmit="true" type="post" onSuccess="onUpdateSucc"/>
	<!-- 修改页面dialog -->
	<tags:dialog id="staffEditDialog" size="modal-lg">
		<link href="${ctxStaticSystem }/css/knowledge/manage/knowledge.css" rel="stylesheet" type="text/css"/>
		<script src="${ctxStaticSystem }/js/staff/staff.js" type="text/javascript" ></script>
		<!-- 角色表查询 -->
		<tags:ajax id="queryRoleInfoListAjax"
			url="${ctx }/sys/roleMgr/roleList" autoSend='false' type='post'
			formSubmit="true" formQuery="#roleOldInfoFrm"/>
		<!-- 查询员工角色 -->
		<%-- <tags:ajax id="findStaffRolesAjax" url="${ctx }/system/staff/findRolesByUserId"
			autoSend="false" type="post" contentType="application/x-www-form-urlencoded"
			onSuccess="onFindStaffRoleSucc"/> --%>
		<!-- 保存员工角色 -->
		<tags:ajax id="saveStaffRolesAjax" url="${ctx }/sys/staffMgr/editStaffInfoAndRoles"
			autoSend="false" type="post" formQuery="#staffBaseInfoFrm" formSubmit="true"
			onSuccess="onSaveSucc"/>
		<tags:dataSet id="roleInfoSet">
			<tags:dataField sort="false" name="roleId" display="" visiable="false" cssClass="table-header-center"/>
			<tags:dataField sort="false" name="roleName" display="角色名称" cssClass="table-header-center"/>
			<tags:dataField sort="false" name="state" display="状态" cssClass="table-header-center"/>
			<tags:dataField sort="false" name="roleType" display="操作" cssClass="table-header-center"/>
		</tags:dataSet>
		<tags:dialogHeader title="员工信息修改"/>
		<tags:dialogBody>
			<div class="baseInfoDiv">
				<form id="staffBaseInfoFrm">
					<input name="staffId" style="display:none">
					<input name="roleIds" id="staffHasRoles" style="display:none">
					<div class="col-md-4">
						<span>员工姓名:</span>
						<input name="staffName" class="disInput" readonly="readonly">
					</div>
					<div class="col-md-4">
						<span>手机号:</span>
						<input name="staffTel" class="disInput" readonly="readonly">
					</div>
					<div class="col-md-4">
						<span>邮箱:</span>
						<input name="mailAdd" class="disInput" readonly="readonly">
					</div>
				</form>
			</div>
			<div class="hasRolesDiv">
				<form action="" id="hasRolesFrm">
					<fieldset>
						<legend>已拥有角色</legend>
						<div class="rolesShowDiv">
						
						</div>
					</fieldset>
				</form>
			</div>
			<div>
				<form action="" id="roleOldInfoFrm">
					<fieldset>
						<legend>所有角色</legend>
						<div class="input-group col-md-4 searDiv">
							<input type="text" name="roleName" class="form-control" placeholder="角色名称">
			  				<span class="input-group-btn">
							    <button class="btn btn-primary m-btn" type="button" onclick="searchName()">搜索</button>
							</span>
						</div>
						<div>
							<tags:datatable id="staffRoleDatatable" storage="false"
								ajax="queryRoleInfoListAjax" pagination="roleMananagePagination"
								dataSet="roleInfoSet" automatic="false"
								striped="true" cutLine="true"
								onRenderItem="tableO.onRoleRenderItem"
								afterReady="tableO.onAfterReady"/>
							<tags:pagination pageSize="5" id="roleMananagePagination" 
								pageChoice="5" datatable="staffRoleDatatable" />
						</div>
					</fieldset>
				</form>
		 	</div>
		</tags:dialogBody>
		<tags:dialogFooter>
			<button class="btn btn-primary m-btn" id="saveChanges" onclick="saveAll()">提交</button>
			<button class="btn btn-default m-btn" id="closeDia" onclick="closeDia()">关闭</button>
		</tags:dialogFooter>
	</tags:dialog>

<%--新增员工信息--%>
<tags:dialog id="createStaffDialog">
	<tags:dialogHeader title="新增员工信息"/>
	<tags:dialogBody>
		<form action="" id="createStaffFrm">
			<div class='form-horizontal'>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>员工姓名：</span>
						</div>
						<div class="col-md-9">
							<input id="staffName1" name="staffName" type="text" class="inputC form-control" required="required">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</span>
						</div>
						<div class="col-md-9">
							<%--<input id="staffSex" name="staffSex" type="text" class="inputC form-control" required="required">--%>
								<select id="staffSex" name="staffSex" class="inputC form-control">
									<option value="男">男</option>
									<option value="女">女</option>
								</select>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>登录密码：</span>
						</div>
						<div class="col-md-9">
							<input id="staffPwd1" name="staffPwd" type="text" class="inputC form-control" required="required">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>所属机构：</span>
						</div>
						<div class="col-md-9">
							<div class="input-group">
								<input  id="staffNetId1"   name="staffNetId" type="hidden" class="form-control" required="required">
								<input style="width: 80%" id="staffNetName1" name="staffNetName" type="text" readonly="readonly" class="form-control" data-toggle="tooltip">
								<span class="input-group-btn" style="float:left">
									<button class="btn btn-warning" type="button" onclick="btnEvents.alertTree('1')">选择</button>
								</span>
							</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>所属区域：</span>
						</div>
						<div class="col-md-9">
							<input id="belongArea1" name="belongArea" type="text" class="inputC form-control" required="required">

						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>用户编号：</span>
						</div>
						<div class="col-md-9">
							<input id="staffId1" name="staffId" type="text" class="inputC form-control" required="required">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>电话号码：</span>
						</div>
						<div class="col-md-9">
							<input id="staffTel1" name="staffTel" type="text" class="inputC form-control" >
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>身份证号：</span>
						</div>
						<div class="col-md-9">
							<input id="staffIdCard1" name="staffIdCard" type="text" class="inputC form-control" >
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</span>
						</div>
						<div class="col-md-9">
							<%--<input name="state" type="text" class="inputC form-control" required="required">--%>
								<select name="state" class="inputC form-control">
									<option value="1">正常</option>
									<option value="0">禁用</option>
								</select>
						</div>

					</div>
				</div>
			</div>
		</form>
	</tags:dialogBody>
	<tags:dialogFooter>
		<div>
			<div class="col-sm-12"><!-- editBtnArea -->
				<button class="btn btn-primary m-btn" onclick="btnEvents.commitAddStaff()">提交</button>
				<button type="reset" class="btn btn-default m-btn" data-dismiss="modal">取消</button>
			</div>
		</div>
	</tags:dialogFooter>
</tags:dialog>


<%--修改员工信息--%>
<tags:dialog id="updateStaffDialog">
	<tags:dialogHeader title="新增员工信息"/>
	<tags:dialogBody>
		<form action="" id="updateStaffFrm">
			<div class='form-horizontal'>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>员工姓名：</span>
						</div>
						<div class="col-md-9">
							<input id="staffName2" name="staffName" type="text" class="inputC form-control" required="required">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</span>
						</div>
						<div class="col-md-9">
								<%--<input id="staffSex" name="staffSex" type="text" class="inputC form-control" required="required">--%>
							<select name="staffSex" class="inputC form-control">
								<option value="男">男</option>
								<option value="女">女</option>
							</select>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>登录密码：</span>
						</div>
						<div class="col-md-9">
							<input placeholder="仅需要修改密码时填写" id="staffPwd2" name="staffPwd" type="text" class="inputC form-control" required="required">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>所属机构：</span>
						</div>
						<div class="col-md-9">
							<div class="input-group">
								<input  id="staffNetId2"   name="staffNetId" type="hidden" class="form-control" required="required">
								<input style="width: 80%" id="staffNetName2" name="staffNetName" type="text" readonly="readonly" class="form-control" data-toggle="tooltip">
								<span class="input-group-btn" style="float:left">
									<button class="btn btn-warning" type="button" onclick="btnEvents.alertTree('2')">选择</button>
								</span>
							</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>所属区域：</span>
						</div>
						<div class="col-md-9">
								<input id="belongArea2" name="belongArea" type="text" class="inputC form-control" required="required">
							<%--<select name="belongArea" class="inputC form-control">
								<option value="北京">北京</option>
								<option value="上海">上海</option>
								<option value="天津">天津</option>
								<option value="重庆">重庆</option>
								<option value="黑龙江">黑龙江</option>
								<option value="辽宁">辽宁</option>
								<option value="吉林">吉林</option>
								<option value="河北">河北</option>
								<option value="河南">河南</option>
								<option value="湖北">湖北</option>
								<option value="湖南">湖南</option>
								<option value="山东">山东</option>
								<option value="山西">山西</option>
								<option value="陕西">陕西</option>
								<option value="安徽">安徽</option>
								<option value="浙江">浙江</option>
								<option value="江苏">江苏</option>
								<option value="福建">福建</option>
								<option value="广东">广东</option>
								<option value="海南">海南</option>
								<option value="四川">四川</option>
								<option value="云南">云南</option>
								<option value="贵州">贵州</option>
								<option value="青海">青海</option>
								<option value="甘肃">甘肃</option>
								<option value="0">江西</option>
								<option value="0">台湾</option>
							</select>--%>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>用户编号：</span>
						</div>
						<div class="col-md-9">
							<input name="staffId" type="text" class="inputC form-control" readonly required="required">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>电话号码：</span>
						</div>
						<div class="col-md-9">
							<input id="staffTel2" name="staffTel" type="text" class="inputC form-control" >
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>身份证号：</span>
						</div>
						<div class="col-md-9">
							<input id="staffIdCard2" name="staffIdCard" type="text" class="inputC form-control" >
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12 outr">
						<div class="col-md-3 iname">
							<span>状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</span>
						</div>
						<div class="col-md-9">
								<%--<input name="state" type="text" class="inputC form-control" required="required">--%>
							<select name="state" class="inputC form-control">
								<option value="1">正常</option>
								<option value="0">禁用</option>
							</select>
						</div>

					</div>
				</div>
			</div>
		</form>
	</tags:dialogBody>
	<tags:dialogFooter>
		<div>
			<div class="col-sm-12"><!-- editBtnArea -->
				<button class="btn btn-primary m-btn" onclick="btnEvents.commitUpdateStaff()">提交</button>
				<button type="reset" class="btn btn-default m-btn" data-dismiss="modal">取消</button>
			</div>
		</div>
	</tags:dialogFooter>
</tags:dialog>

<%--弹出机构树--%>
<tags:dialog id="alertTreeDialog">
	<tags:dialogHeader title="所属机构"/>
	<tags:dialogBody>
		<%--弹出tree--%>

		<tags:ajax id="alertOrgsAjax" url="${ctx}/sys/orgMgr/queryAllOrg" type="post"
				   onBeforeSend="showTr.showloading" onComplete="showTr.closeloading"/>
		<div id="showTree" class="showTree">
			<div id="orgloading1" class="orgloading1" style="display:none">
				<i class="icon icon-spin icon-spinner-indicator icon-3x"></i>
			</div>
			<tags:tree ajax="alertOrgsAjax" id="orgsStaffTree1" showLine="true"
					   nodeNameKey="orgName" nodeId="orgId" parentId="parOrgId"
					   nodeChildrenKey="children" nodeTitleKey="orgName"
					   checkable="true" />
		</div>
	</tags:dialogBody>
	<tags:dialogFooter>
		<div>
			<div class="col-sm-12"><!-- editBtnArea -->
				<button class="btn btn-primary m-btn" onclick="btnEvents.commitOrg()">确认</button>
				<button type="reset" class="btn btn-default m-btn" data-dismiss="modal">取消</button>
			</div>
		</div>
	</tags:dialogFooter>
</tags:dialog>
<tags:boards>
	<tags:board width="30%" boardTitle="部门树">
			<div class="opreate">
				<span title="刷新">
					<a href="javascript:;" onclick="treeFresh()">
						<i class="icon icon-repeat"></i>
					</a>
				</span>
			</div>
			<div id="showTree" class="showTree">
				<div id="orgloading" class="orgloading" style="display:none">
					<i class="icon icon-spin icon-spinner-indicator icon-3x"></i>
				</div>
				<tags:tree ajax="queryOrgsAjax" id="orgsStaffTree" showLine="true"
					nodeNameKey="orgName" nodeId="orgId" parentId="parOrgId" 
					nodeChildrenKey="children" nodeTitleKey="orgName"
					onCurrentNodeSelected="" checkable="true" />
			</div>
	</tags:board>
	<tags:board boardTitle="员工信息" width="70%">
			<div class="form-horizontal minH">
				<div class=" form-group">
					<form id="staffQueryFrm">
					<input name="orgIds" style="display:none">
					<div class="row">
				  		<div class="col-md-6 form-group outrDiv">
				  			<div class="col-md-3 item">
				  				<label>员工编号：</label>
				  			</div>
							<div class="col-md-9">
								<input name="staffId" class="form-control" id="staffId" type="text">
							</div>	
				  		</div>
				  		<div class="col-md-6 form-group outrDiv">
				  			<div class="col-md-3 item">
							 	<label >员工名称：</label>
							 </div>
							<div class="col-md-9">
								<input name="staffName" class="form-control" id="staffName" type="text">
							</div>	
				  		</div>
					</div> 
					<div class="row form-horizontal">
					  <div class="col-xs-6 form-group outrDiv">
					  	<div class="col-md-3 item">
					  		<label class="form-label">状态：</label>
					  	</div>
					    <div class="col-md-9">
							   <select name="state" id="state" class="form-control">
								  <option value="">请选择</option>
								  <option value="1">正常</option>
								  <option value="0">禁用</option>
								</select>
						 </div>
					  </div>
					 <div class="col-xs-6 form-group outrDiv">
					 	<div class="col-md-3 item">
					 		<label class="form-label">角色名称：</label>
					 	</div>
					    <div  class="col-md-9">
							<input name="roleName" class="form-control" id="roleName" type="text">
						</div>
					  </div>
					</div>
					<div class="col-xs-12 form-group input-group btnArea">
					   	<button class="btn btn-warning m-btn" type="button" onclick="btnEvents.query()">查询</button>
					  	<button class="btn btn-default m-btn" type="button" onclick="btnEvents.reset()">重置</button>
						<button class="btn btn-success m-btn" onclick="btnEvents.onAddStaff();return false;">新增</button>
						<button class="btn btn-primary m-btn" onclick="btnEvents.onUpdateStaff();return false;">修改</button>
						<button class="btn btn-primary m-btn" onclick="btnEvents.onDelStaff();return false;">删除</button>
					 </div>
					<div data-tag="员工列表" class="form-horizontal">
						<tags:datatable id="staffInfoDataTable" storage="false" checkable="true" checkByClickRow="true"
							ajax="queryStaffListAjax" dataSet="staffInfo" 
							pagination="staffInfoPagination" striped="true"
							single="true" onRenderItem="onRenderItem"
							afterReady="editStaffInfo"
							cutLine="true" />
						<tags:pagination pageSize="15" id="staffInfoPagination" pageChoice="15" datatable="staffInfoDataTable"/>	
					</div>
				 </form>
			</div>
		</div>
	</tags:board>
</tags:boards>
</body>
	
</html>